﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XZL.GM.Bll;
using XZL.GM.Dal;

public partial class Admin_Course_VideoList : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindVideoList();

        }
    }


    private void BindVideoList()
    {
        int? count = 0;
        string str = Request.QueryString["CourseID"];   
        int uID = Convert.ToInt32(str);
        divCondition.Visible = true;
        gridList.DataSource = VideoInfoBiz.GetVideoList(uID, netPager.CurrentPageIndex, netPager.PageSize, ref count);
        gridList.DataBind();
        netPager.RecordCount = count.Value;
        lblWarn.Text = "视频数量:" + count.Value;
    
    }


    /// <summary>
    /// 分页控件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void netPager_PageChanged(object sender, EventArgs e)
    {
        BindVideoList();
    }

    protected void btnSelect_Click(object sender, EventArgs e)
    {
        BindVideoList();
        netPager.CurrentPageIndex = 1;
    }


    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gridList_RowDeleting(object sender, GridViewDeleteEventArgs e) 
    {
        string ItemID = gridList.DataKeys[e.RowIndex].Value.ToString(); ;
        int rID = Convert.ToInt32(ItemID);
        bool b = VideoInfoBiz.DeleteVideo(rID);
        if (b)
        {
            lblWarn.Text = "删除成功";
            BindVideoList();
        }
    
    }



    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string link = "VideoAdd.aspx?CourseID=" + Request.QueryString["CourseID"];   
        Response.Redirect(link);
    }
}